// 数组去重
var arr = [1, 2, 3, 3, "4", "4"];

// 1. 利用 ES6 Set
var arr1 = [...new Set(arr)];
console.log("利用 ES6 Set 去重", arr1);

// 2. 利用对象去重
Array.prototype.fillRepeat1 = function () {
  var self = this,
    tem = {},
    res = [];

  for (let i = 0; i < self.length; i++) {
    if (tem[self[i]] === undefined) {
      res.push(self[i]);
    }
    tem[self[i]] = true;
  }

  return res;
};
var arr2 = arr.fillRepeat1();
console.log("利用对象去重", arr2);

// 3. 利用数组下标去重
Array.prototype.fillRepeat2 = function () {
  var self = this,
    res = [];

  for (let i = 0; i < self.length; i++) {
    if (self.indexOf(self[i]) === i) {
      res.push(self[i]);
    }
  }

  return res;
};
var arr3 = arr.fillRepeat2();
console.log("利用数组下标去重", arr3);